const app = getApp()

Page({
    /**
     * 页面的初始数据
     */
    data: {
        musiclist: []
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        const playHistory = wx.getStorageSync(app.globalData.openid)
        if (playHistory.length == 0) {
            wx.showModal({
                title: '播放历史为空',
                content: '',
                complete: (res) => {
                    wx.navigateBack()
                }
            })
        } else {
            // 将 storage 里存储的 musiclist 替换成播放历史的歌单
            wx.setStorage({
                key: 'musiclist',
                data: playHistory,
            })
            this.setData({
                musiclist: playHistory
            })
        }
    }
})